<!DOCTYPE html>
<html>
<head>
	<title>解构的用途</title>
</head>
<body>
<script type="text/javascript">
	
// 1. 交换变量
let [a, b] = [1, 2];
[a, b] = [b, a];
console.log(a, b);


// 2. 合并数组
let arra = [1, 2, 3];
let arrb = [12, 22, 32];
console.log([...arra, ...arrb]);

// 2. 提取json
let json = {
	id: 1,
	names: ['cuihao', 'li'] 
}
let {id, names: str} = json;
console.log(id, str); 


// 3. 函数的默认参数
function fun(arg=12) {
}


// 4. 模块的指定导入
// const { SourceMapConsumer, SourceNode } = require("source-map");

</script>
</body>
</html>